package com.rc.saas.tenant.service.hlht;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.order.OrderInfoMapper;
import com.rc.saas.tenant.model.hlht.HlhtTenantOpen;
import com.rc.saas.tenant.model.tenant.TenantUser;
import com.rc.saas.tenant.search.hlht.HlhtOrderSearch;
import com.rc.saas.tenant.vo.hlht.HlhtOrderPrintVo;
import com.rc.saas.tenant.vo.hlht.HlhtOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HlhtOrderServiceImpl implements HlhtOrderService {

    @Autowired
    private OrderInfoMapper orderInfoMapper;

    @Autowired
    private HlhtTenantOpenService hlhtTenantOpenService;

    /*@Override
    public PageInfo<HlhtOrderVo> listPageHlhtOrderInfo(HlhtOrderSearch hlhtOrderSearch, TenantUser user) {
        HlhtTenantOpen hlhtTenantOpen = hlhtTenantOpenService.selectByPrimaryKey(hlhtOrderSearch.getTenantOpenId());
        String tenantCode = hlhtTenantOpen.getTenantCode();
        String hlhtOpenType = hlhtTenantOpen.getHlhtOpenType();
        String hlhtTenantCode = hlhtTenantOpen.getHlhtTenantCode();
        String hlhtOperatorId = hlhtTenantOpen.getHlhtOperatorId();
        String hlhtType = hlhtTenantOpen.getHlhtType();

        if ("0".equals(hlhtOpenType)){
            hlhtOrderSearch.setHlhtOpenType("0");
            if (tenantCode.equals(hlhtOrderSearch.getTenantCode())){
                hlhtOrderSearch.setTenantCode(tenantCode);
                hlhtOrderSearch.setHlhtTenantCode(hlhtTenantCode);
                if ("0".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("1");
                }else if ("1".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("2");
                }

            }else {
                hlhtOrderSearch.setTenantCode(hlhtTenantCode);
                hlhtOrderSearch.setHlhtTenantCode(tenantCode);
                if ("0".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("2");
                }else if ("1".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("1");
                }
            }
        }else if ("1".equals(hlhtOpenType) || "2".equals(hlhtOpenType)){
            hlhtOrderSearch.setTenantCode(tenantCode);
            hlhtOrderSearch.setHlhtOperatorId(hlhtOperatorId);
            hlhtOrderSearch.setHlhtOpenType(hlhtOpenType);
            if ("0".equals(hlhtType)){
                hlhtOrderSearch.setHlhtOrderType("1");
            }else if ("1".equals(hlhtType)){
                hlhtOrderSearch.setHlhtOrderType("2");
            }
        }

        PageHelper.startPage(hlhtOrderSearch.getOffset(), hlhtOrderSearch.getLimit());
        List<HlhtOrderVo> orderList = orderInfoMapper.listPageHlhtOrderInfo(hlhtOrderSearch);
        return new PageInfo<HlhtOrderVo>(orderList);
    }*/

   /* @Override
    public List<HlhtOrderPrintVo> listHlhtOrderInfo(HlhtOrderSearch hlhtOrderSearch) {
        HlhtTenantOpen hlhtTenantOpen = hlhtTenantOpenService.selectByPrimaryKey(hlhtOrderSearch.getTenantOpenId());
        String tenantCode = hlhtTenantOpen.getTenantCode();
        String hlhtOpenType = hlhtTenantOpen.getHlhtOpenType();
        String hlhtTenantCode = hlhtTenantOpen.getHlhtTenantCode();
        String hlhtOperatorId = hlhtTenantOpen.getHlhtOperatorId();
        String hlhtType = hlhtTenantOpen.getHlhtType();

        if ("0".equals(hlhtOpenType)){
            hlhtOrderSearch.setHlhtOpenType("0");
            if (tenantCode.equals(hlhtOrderSearch.getTenantCode())){
                hlhtOrderSearch.setTenantCode(tenantCode);
                hlhtOrderSearch.setHlhtTenantCode(hlhtTenantCode);
                if ("0".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("1");
                }else if ("1".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("2");
                }

            }else {
                hlhtOrderSearch.setTenantCode(hlhtTenantCode);
                hlhtOrderSearch.setHlhtTenantCode(tenantCode);
                if ("0".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("2");
                }else if ("1".equals(hlhtType)){
                    hlhtOrderSearch.setHlhtOrderType("1");
                }
            }
        }else if ("1".equals(hlhtOpenType) || "2".equals(hlhtOpenType)){
            hlhtOrderSearch.setTenantCode(tenantCode);
            hlhtOrderSearch.setHlhtOperatorId(hlhtOperatorId);
            hlhtOrderSearch.setHlhtOpenType(hlhtOpenType);
            if ("0".equals(hlhtType)){
                hlhtOrderSearch.setHlhtOrderType("1");
            }else if ("1".equals(hlhtType)){
                hlhtOrderSearch.setHlhtOrderType("2");
            }
        }
        List<HlhtOrderPrintVo> orderList = orderInfoMapper.listHlhtOrderInfo(hlhtOrderSearch);
        return orderList;
    }*/
}
